package com.zhw.controller;

import com.zhw.pojo.Result;
import com.zhw.pojo.dto.UpdatePasswordDTO;
import com.zhw.pojo.entry.User;
import com.zhw.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Update;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@Slf4j
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserService userService;



    @PutMapping("updatePass")
    public Result updatePass(@RequestBody UpdatePasswordDTO user){
        log.info("修改用户密码：{}",user);
        userService.updatePass(user);
        return Result.success();
    }



    @GetMapping("info")
    public Result getUserInfo(){
        log.info("获取当前登录用户信息");
        User u=userService.getUserInfo();
        return Result.success(u);
    }

    @GetMapping("username")
    public Result getUsername(){
        log.info("获取当前存在的所有用户名");
        List<Map<String,String>> usernames=userService.getUserName();
        return Result.success(usernames);
    }


}
